<#assign base=request.contextPath />
<#import "/tags/select.ftl" as items />
<!DOCTYPE html>
<html>
<head>
  <base href="${base}">	
  <meta charset="utf-8">
  <title>增加机构</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="${base}/layuiadmin/layui/css/layui.css" media="all">
  <link rel="stylesheet" href="${base}/css/my.css" media="all">
</head>

<body>
  	<div class="layui-form" lay-filter="LAY-form-list" style="padding: 20px 30px 0 0;">
  		<input type="hidden" name="depId" value="${(dept.depId)!}">
  		<input type="hidden" name="orgSupId" value="${(parent.depId)!0}">
  		<div class="layui-form-item flex1">
      		<label class="layui-form-label">上级名称</label>
      		<div class="layui-input-block">
        		<input type="text" value="${(parent.depName)!'根'}" readonly="readonly" autocomplete="off" class="layui-input">
      		</div>
    	</div>
    	<div class="layui-form-item flex1">
      		<label class="layui-form-label required">机构名称</label>
      		<div class="layui-input-block">
        		<input type="text" name="depName" value="${(dept.depName)!}" lay-verify="required" placeholder="请输入机构名称" autocomplete="off" class="layui-input">
      		</div>
    	</div>   
    	<div class="layui-form-item">
      		<label class="layui-form-label required">机构类型</label>
      		<div class="layui-input-block">
      			<@items.select id="orgType" value="${(dept.orgType)!}" verify="required" datas=[['0', '学院'], ['1', '年级'], ['2', '班级'], ['9', '其他组织']] />
      		</div>
      	</div>
      	<div class="layui-form-item">
      		<label class="layui-form-label required">机构代码</label>
      		<div class="layui-input-block">
      			<input type="text" name="code" value="${(dept.code)!}" lay-verify="required" placeholder="请输入机构代码" autocomplete="off" class="layui-input">
      		</div>
    	</div>   
    	<div class="layui-form-item flex1">
	      	<label class="layui-form-label">机构描述</label>
	      	<div class="layui-input-block">
	        	<textarea name="orgDesc" style="height:100px;" autocomplete="off" class="layui-textarea">${(dept.orgDesc)!}</textarea>
	      	</div>
	    </div>        
	    <div class="layui-form-item layui-hide">
	      	<input type="button" lay-submit lay-filter="LAY-form-submit" id="LAY-form-submit" value="确认添加">
	      	<input type="button" lay-submit lay-filter="LAY-form-edit" id="LAY-form-edit" value="确认编辑">
	    </div>
  	</div>

  <script src="${base}/layuiadmin/layui/layui.js"></script>  
  <script>
  	layui.config({
    	base: '${base}/layuiadmin/' //静态资源所在路径
  	}).extend({
    	index: 'lib/index',
    	jwt: '{/}${base}/js/lib/jwt'
  	}).use(['index', 'form', 'jwt'], function(){
    	var $ = layui.$,
    		form = layui.form,
    		jwt = layui.jwt;
    
    	//监听提交
    	form.on('submit(LAY-form-submit)', function(data) {
      		var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引  
      		//提交ajax成功后，关闭当前弹层并重载表格
      		jwt.ajax({
      			url: '${base}/system/dept/save',
      			data: data.field,
      			success: function(json) {
      				parent.layui.table.reload('LAY-table'); //重载表格
      	      		parent.layer.close(index); //再执行关闭      				
      			}
      		});
    	});
  	})
  </script>
</body>
</html>